package com.esd.crm.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.esd.crm.entity.User;
import com.esd.crm.mapper.UserMapper;
import com.esd.crm.service.UserService;
import com.esd.vo.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service
public class UserServiceImpl implements UserService{
	@Autowired
	private UserMapper userDao;

	
	@Override
	public User getUserInfo(String userId) {
		return userDao.selectByPrimaryKey(userId);
	}

	@Override
	public boolean insertSelective(User user) {
		return userDao.insertSelective(user);
	}

	@Override
	public boolean deleteById(String userId) {
		return userDao.deleteByPrimaryKey(userId);
	}

	@Override
	public boolean updateByPrimaryKeySelective(User user) {
		Date date = new Date();
		user.setUpdateTime(date);
		return userDao.updateByPrimaryKeySelective(user);
	}

	@Override
	public User findOneByUserName(String username) {
		return userDao.findOneByUserName(username);
	}

	@Override
	public List<User> findAll(User user) {
		return userDao.findAll(user);
	}

	@Override
	public PageInfo<User> findByPage(User user, PageUtil page) {
		PageHelper.startPage(page.getNowPage(), page.getNowRows());
		List<User> users = userDao.findAll(user);
		System.out.println("users.size==>"+users.size());
		PageInfo<User> pageInfo = new PageInfo<>(users);
		return pageInfo;
	}

	@Override
	public boolean deleteBatch(String[] ids) {
		return userDao.deleteBatch(ids);
	}

	

	
	
	

	
}
